package com.hong.springcloud.service;

import com.hong.springcloud.entity.Product;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Map;

/**
 * Created by John on 2018/11/25.
 */
@FeignClient(value = "microservice-product",fallbackFactory=ProductClientServiceFallbackFactory.class)
public interface ProductClientService {
    /**
     * 使用Feign声明式服务调用,看的是接口方法头上标注的@RequestMapping，
     * 调用声明式接口中的方法实际调用的是@FeignClient(value = "microservice-product")
     * 标识的服务中的映射路径为@RequestMapping所声明的路径,
     * 注意声明式接口中的方法签名需要与映射路径对应的方法签名一致
     * @param id
     * @return
     */
    @RequestMapping(value = "/product/get/{id}", method = RequestMethod.GET)
    Product get(@PathVariable("id") Long id);
    @RequestMapping(value = "/product/list", method = RequestMethod.GET)
    Map<String,Object> list();
    @RequestMapping(value = "/product/add", method = RequestMethod.POST)
    int add(Product product);
}
